using System;
using nDeveloper.Data;
using nDeveloper.BO.Base;
using nDeveloper.BO.Base.Domain;

namespace ExemploWinAppCS.BO.DataAccess
{
    public abstract class BaseDb : IDisposable
    {
        protected BaseDataAccess con;
        protected SqlConvert SQLConvert;

        protected BaseDb()
        {
            this.con = new BaseDataAccess(DataBaseConfig.GetConnectionString(), RetornaProviderConfigurado(), true);
            this.SQLConvert = new SqlConvert(RetornaProviderConfigurado());
        }

        private static Providers RetornaProviderConfigurado()
        {
            Providers prov;

            switch (DataBaseConfig.GetServerType())
            {
                case Constants.vsDataBase.SQLServer2000:
                case Constants.vsDataBase.SQLServer2005:
                    prov = Providers.SqlServer;
                    break;

                case Constants.vsDataBase.Oracle:
                    prov = Providers.Oracle;
                    break;

                case Constants.vsDataBase.MySQL:
                    prov = Providers.MySql;
                    break;

                default:
                    prov = Providers.SqlServer;
                    break;
            }

            return prov;
        }

        public virtual void Dispose()
        {
        }
    }
}